using System;
using System.ComponentModel;
using System.Xml.Serialization;

namespace com.exceptionalsoftware.spacetime.KML
{
	[Serializable()]
    [XmlType(TypeName = "SnippetType")]
    public class Snippet
	{
        private int maxLinesField;
        private string contentField;

        public Snippet()
        {
            this.maxLinesField = 2;
        }

        public Snippet(string content):this()
        {
            this.contentField = content;
        }

        public Snippet(string content, int maxLines)
            : this(content)
        {
            this.setMaxLines(maxLines);
        }

        [XmlAttribute(AttributeName = "maxLines", DataType = "int")]
        [DefaultValueAttribute(2)]
        public int MaxLines
        {
            get { return this.maxLinesField; }
            set { this.maxLinesField = value; }
        }

        [XmlText(DataType="string")]
        public string Content
        {
            get { return this.contentField; }
            set { this.contentField = value; }
        }

        private void setMaxLines(int max)
        {
            if (max < 1)
                max = 2;

            this.maxLinesField = max;
        }
    }
}